﻿#region 命名空间

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection;
using WinnerCMS.Common;
using WinnerCMS.BLL;
using WinnerCMS.Model;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Vote
{
    [Access("258003")]
    public partial class Manage : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList(1);
            }
        }

        public void BindList(int pageNo)
        {
            var pp = new PagingParam();
            pp.PageSize = this.PageNavigation1.PageSize;
            pp.PageNo = pageNo;

            this.GV_List.DataSource = new VoteManage().BindList(pp);
            this.GV_List.DataBind();
            this.PageNavigation1.RecordCount = pp.RecordCount;
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            var IDs = GetSelectedRow.GetIDs(this.GV_List);

            PolicyInjection.Create<VoteManage>().Delete(IDs);

            HttpContext.Current.Response.Redirect("Manage.aspx");
        }

        protected void PageNavigation1_PageChanging(object src, WebControls.PageChangingEventArgs e)
        {
            BindList(e.NewPageIndex);
        }

        protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }
            var tc = e.Row.Cells[5];
            if (tc.Text == "True")
            {
                tc.Text = "单选";
            }
            else
            {
                tc.Text = "多选";
            }
        }
    }
}